package cn.pid21.client.model;

import java.util.Date;
import java.util.List;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;

import cn.pid21.client.model.datapid.Contributor;
import cn.pid21.client.model.datapid.Copyright;
import cn.pid21.client.model.datapid.Funder;
import cn.pid21.client.model.datapid.Identifier;
import cn.pid21.client.model.datapid.Relation;
import cn.pid21.client.model.datapid.Subject;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
 * PID 核心元数据
 * 
 * @author 郭志斌
 * @date 2019/07/22
 */
@Getter
@Setter
@ToString
public class Metadata implements PidCoreMetadata {

	/**
     * 资源中文名称  v1 : titleZh
     */
    @NotBlank(message = "资源中文名称 不能为空")
    @JacksonXmlProperty(localName = "resource_chinese_name")
    private String resourceChineseName;
    /**
     * 资源英文名称  v1 : titleEn
     */
    @JacksonXmlProperty(localName = "resource_name")
    private String resourceName;

    /**
     * 名称类型 
     */
    @JacksonXmlProperty(localName = "resource_name_type")
    private String resourceNameType;

    /**
     * PID标识
     */
    @NotBlank(message = "PID标识 不能为空")
    @JacksonXmlProperty(localName = "pid")
    private String pid;

    /**
     * 资源链接地址 v1 : url
     */
    @NotEmpty(message = "资源链接地址 不能为空")
    @JacksonXmlProperty(localName = "resource_address")
    private List<String> resourceAddress;
    

    /**
     * 标识状态 0-草稿,1-可注册,2可发现
     */
    @NotNull(message = "标识状态 不能为空")
    @JacksonXmlProperty(localName = "identification_status")
    private int identificationStatus;

    /**
     * 资源描述（中文）  v1 : descriptionZh
     */
    @NotBlank(message = "描述内容（中文） 不能为空")
    @JacksonXmlProperty(localName = "description_cn")
    private String descriptionCN;

    /**
     * 资源描述（英文） v1 : descriptionEn
     */
    @JacksonXmlProperty(localName = "description_en")
    private String descriptionEN;

    /**
     * 资源类型   
     */
    @NotBlank(message = "资源类型 不能为空")
    @JacksonXmlProperty(localName = "resource_type")
    private String resourceType;

    /**
     * 资源创建者
     */
    @Valid
    @NotEmpty
    @JacksonXmlElementWrapper(localName = "creators")
    @JacksonXmlProperty(localName = "creator")
    private List<Creator> creators;

    /**
     * 资源发布机构(中文) v1:publisherZh
     */
    @NotBlank(message = "资源发布机构(中文) 不能为空")
    @JacksonXmlProperty(localName = "publication_organization_cn")
    private String publicationOrganizationCN;

    /**
     * 资源发布机构(英文) v1:publisherEn
     */
    @JacksonXmlProperty(localName = "publication_organization_en")
    private String publicationOrganizationEN;

    /**
     *资源发布日期
     */
    @NotNull(message = "资源发布日期 不能为空")
    @JacksonXmlProperty(localName = "publication_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date publicationTime;

    /**
     * 贡献者
     */
    @JacksonXmlElementWrapper(localName = "contributors")
    @JacksonXmlProperty(localName = "contributor")
    private List<Contributor> contributors;

    /**
     * 替代标识符
     */
    @JacksonXmlElementWrapper(localName = "alternative_identifiers")
    @JacksonXmlProperty(localName = "identifier")
    private List<Identifier> alternativeIdentifiers;

    /**
     * 关联标识符
     */
    @JacksonXmlElementWrapper(localName = "association_identifiers")
    @JacksonXmlProperty(localName = "relation")
    private List<Relation> associationIdentifiers;

    /**
     * 主题与分类
     */
    @JacksonXmlElementWrapper(localName = "subject_classifications")
    @JacksonXmlProperty(localName = "subject_classification")
    private List<Subject> subjectClassifications;

    /**
     * 版权
     */
    @JacksonXmlElementWrapper(localName = "copyrights")
    @JacksonXmlProperty(localName = "copyright")
    private List<Copyright> copyrights;

    /**
     * 资助者
     */
    @JacksonXmlElementWrapper(localName = "funders")
    @JacksonXmlProperty(localName = "funder")
    private List<Funder> funders;

}
